package parkingshare

import (
	"fmt"
	"net"
	//	"strconv"
)

type SocketConfig struct {
	Host string
	Port int
}

type SocketService struct {
	IsSatrt bool
	Conf    SocketConfig
}

func (service *SocketService) Start() {

	fmt.Println("开始socket服务")
}

func InitServiceSocket(conf SocketConfig) *SocketService {

	if conf.Port > 0 {
		s := new(SocketService)
		s.Conf = conf
		s.IsSatrt = true
		return s

	} else {

		fmt.Println("socket 配置错误")
		return &SocketService{IsSatrt: false}
	}
}
func handleConnection(conn net.Conn) {

	//	tmpBuffer := make([]byte, 0)

	//	buffer := make([]byte, 1024)
	//	messnager := make(chan byte)
	//	for {
	//		n, err := conn.Read(buffer)
	//		if err != nil {
	//			//utils.Log(conn.RemoteAddr().String(), " connection error: ", err)
	//			return
	//		}

	//		//conn.Write("")

	//		//tmpBuffer = utils.Depack(append(tmpBuffer, buffer[:n]...))

	//		//utils.Log("receive data string:", string(tmpBuffer))
	//		//utils.TaskDeliver(tmpBuffer, conn)
	//		//start heartbeating
	//		//go utils.HeartBeating(conn, messnager, timeout)
	//		//check if get message from client
	//		//go utils.GravelChannel(tmpBuffer, messnager)

	//	}
	//	defer conn.Close()

}
